Accusoft.ImagXpress13.ActiveX
Select a Section of the Displayed Image

Use a Rubberband

ImagXpress® enables the user to select a section of the image that is being viewed. This section, referred to as a Rubberband, can then be used in a variety of ways: for example, copied to another control or buffer, or selected as a region to process.

To use a rubberband:

  1. Call the RubberBand method, setting state = true, to initiate a rubberband starting at a specified position.
  2. Call RubberbandUpdate method to update the end coordinates of the rubberband rectangle. The RubberBandH, RubberBandW, RubberBandL and RubberBandT properties are read only properties that return the height, width and coordinates of the rubberband rectangle. These properties update when RubberbandUpdate is called. 
  3. Copy the content framed by the rubberband to a DIB by calling the CopyRubberbandDIB method.   
VB Example
Copy Code
' Activate the rubberband when the user first clicks the mouse
Private Sub ImagXpress1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
     ' CLEAR ANY EXISTING RUBBER BANDING REGION
     ImagXpress1.RubberBand False, X, Y, False
     ' CONVERT X & Y TO PIXELS
     X = X / Screen.TwipsPerPixelX
     Y = Y / Screen.TwipsPerPixelY
 
     ' TURN THE RUBBER BANDING ON, SET THE STARTING POINT
     ImagXpress1.RubberBand True, X, Y, False
End Sub

' Track the user's changes whenever they move the mouse
Private Sub ImagXpress1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
' UPDATE THE RUBBER BAND
X = X / Screen.TwipsPerPixelX
Y = Y / Screen.TwipsPerPixelY
ImagXpress1.RubberbandUpdate X, Y
End Sub

' Do something with the region when the user lifts off the mouse
Private Sub ImagXpress1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim xpos, ypos, w, h As Integer
' YOU CAN DO ANYTHING WITH, OR TO, THE REGION THE USER HAS SELECTED. IN THIS EXAMPLE, WE WILL
' COPY THE AREA TO ANOTHER CONTROL.
ImagXpress2.hDib = ImagXpress1.CopyRubberbandDib
ImagXpress2.ZoomToFit ZOOMFIT_BEST
' TURN THE RUBBER BAND OFF
ImagXpress1.RubberBand False, X, Y, False
End Sub

Use a Sprite

ImagXpress provides capability to create and use a sprite. A sprite is created by copying a part of the displayed image into a transparent window. This window can be moved or pasted within the image view. To create and use a sprite:

  1. Define a part of the displayed image to copy. (This can be done either by defining a RubberbandArea, or a graphics path.)
  2. Create the sprite, by calling the RgnCreateSprite method.
  3. Move the sprite, by calling the RgnMoveSprite method.
  4. To permanently paste the sprite to the object, call the RgnPasteSprite method.

Even if the viewer is assigned a different image to display, the Sprite remains in effect and can be moved or pasted in the new image being viewed.  Therefore, sprites can be used to merge images.

  1. Delete the sprite and free up its resources, by calling the RgnDeleteSprite method.
Deleting the sprite does not result in any changes to the image being viewed.
See Also

 

 


©2018. Accusoft Corporation. All Rights Reserved.

Send Feedback